/**
 * @file:          Filter_MovingAverage.h
 * @brief:         
 * @details:       
 * @author:        wjh
 * @date created:  2023.08.06
 * @version:       1.0.0
 * @par copyright (c):
 *   
 * @par history (desc):
 *   version:1.0.0, wjh, 2023.08.06,11:50:59
 */


#ifndef _FILTER_MOVINGAVERAGE_H_
#define _FILTER_MOVINGAVERAGE_H_

/* Include Files **************************************************************/
#include "Datatype.h"

/* Macro Definition ***********************************************************/
#define MOVING_AVERAGE_MAX_WINDOW_SIZE 10

/* Data Type Define ***********************************************************/
typedef struct Filter_MovingAverage
{
    /* public data */
    uint16_t param_en;
    float param_Ts;
    uint32_t param_N;
    float param_fc;

    float in_x;
    float out_y;
    
    float x_buff[MOVING_AVERAGE_MAX_WINDOW_SIZE];
    uint16 index;
    float x_sum;
    
    /* private data */
    
    /* public method */
    void (*Init)(struct Filter_MovingAverage *self);
    float (*Run)(struct Filter_MovingAverage *self, float in);
    float (*InitBuff)(struct Filter_MovingAverage *self, float init_value);
    void (*UpdateParam)(struct Filter_MovingAverage *self);

    
    /* private method */
    
}Filter_MovingAverage;
    
/* Variable Declare ***********************************************************/

/* Function Declare ***********************************************************/
void Filter_MovingAverage_Init(struct Filter_MovingAverage *self);
float Filter_MovingAverage_Run(struct Filter_MovingAverage *self, float in);
float Filter_MovingAverage_InitBuff(struct Filter_MovingAverage *self, float init_value);
void Filter_MovingAverage_UpdateParam(struct Filter_MovingAverage *self);


#endif